import axios from 'axios';
axios.defaults.withCredentials = true ;
import * as util from '../assets/util.js';

const instance = axios.create({
    baseURL: 'http://127.0.0.1',
    timeout: 10000
});
if(sessionStorage.getItem("token")){
    instance.defaults.headers.common['Authorization'] = sessionStorage.getItem("token");
}
instance.defaults.headers.post['Content-Type'] = 'application/json';
//错误处理
instance.interceptors.response.use(function(response) {
    return response;
}, util.catchError);

export default instance;